#!/usr/bin/perl

use Tk;
use strict;
use warnings;


# canvas variables
my $canvas_width    = 800;
my $canvas_height   = 600;

# zoom variables
my ($x_center, $y_center, $zoom);


# intialisation
# default zoom values
$x_center = 400;
$y_center = 300;
$zoom     = 1.0;


my $mw = new MainWindow();

my $menu_bar = $mw -> Menu();

# create the File menu
my $file_menu = $menu_bar -> Menu(-tearoff => 0);

$file_menu -> add('command',
	-label   => 'Exit',
	-command => sub { exit 0 }
);

$menu_bar -> add('cascade',
	-label   => 'File',
	-menu    => $file_menu,
);


# create the edit menu

# create the draw menu
my $draw_menu = $menu_bar -> Menu(-tearoff => 0);

$draw_menu -> add('command',
	-label      => 'Lines',
);

$draw_menu -> add('command',
	-label      => 'Polylines',
);

$menu_bar -> add('cascade',
	-label    => 'Draw',
	-menu     => $draw_menu,
);

# create the snap menu
my $snap_menu = $menu_bar -> Menu(
	-tearoff => 1,
	-title   => 'Snap',
);

$snap_menu -> add('command',
	-label     => 'Endpoints',
);

$snap_menu -> add('command',
	-label     => 'Midpoints',
);

$snap_menu -> add('command',
	-label     => 'Intersections',
);

$menu_bar -> add('cascade',
	-label     => 'Snap',
	-menu      => $snap_menu,
);


# create the tools menu
my $tools_menu = $menu_bar -> Menu(
	-tearoff => 0,
);

$tools_menu -> add('command',
	-label      => 'Trim or extend',
);

$tools_menu -> add('command',
	-label      => 'Make joining',
);

$tools_menu -> add('command',
	-label      => 'Fillet',
);

$tools_menu -> add('command',
	-label      => 'Chamfer',
);

$menu_bar -> add('cascade',
	-label      => 'Tools',
	-menu       => $tools_menu,
); 
	

my $help_menu = $menu_bar -> Menu();

$help_menu -> add('command',
	-label      => 'About',
);

$menu_bar -> add('cascade',
	-label      => 'Help',
	-menu       => $help_menu,
);


# done configuring menus; configure the menu bar
$mw -> configure (-menu => $menu_bar);


my $can = $mw -> Canvas(
	-width     => $canvas_width,
	-height    => $canvas_height,
);

$can -> pack();
           
MainLoop();

